﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLDC.Common.Estate;
using System.Data;

namespace ZLDC.Estate.PM
{
    public partial class EstateChangeInput : _PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (_Utility.GetWebConfigSetting("OpenDept").Contains(this.info.m_sDeptID))
                {
                    _Utility.GoError("营业部楼盘整理待完善中，避免出现抢盘，暂时不开放录盘功能！");
                    return;
                }


                if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("上盘待审"))
                    isValid.Value = "0";


                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadUsageAll(use, false, "用途"); 
                use.Items.Insert(0, "请选择");
                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadIDParamType(tradeType, true, "交易(盘)");
              
                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadMarkParamType(status, false, "状态");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(source, false, "来源");
                source.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(pocStatus, false, "房产证状态");
                pocStatus.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(houseStyle, false, "样式");
                houseStyle.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(direct, false, "朝向");
                direct.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(fitment, false, "装修");

                fitment.Items.Insert(0, "请选择");
                
                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(useStatus, false, "使用状态");
                useStatus.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(propertyRight, false, "产权");
                propertyRight.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(mark2, false, "营业税");
                mark2.Items.Insert(0, "请选择");
                
                //加载开盘人信息
                markUDept1.Value = this.info.m_sDeptName;
                markUDeptId1.Value=this.info.m_sDeptID;
                markUId1.Value = this.info.m_sUserID;
                markUser1.Value = this.info.m_sUserName;
                //加载录入信息
                addUId1.Value = this.info.m_sUserID;
                addUser1.Value = this.info.m_sUserName;
                addUDept1.Value = this.info.m_sDeptName;
                addUDeptId1.Value = this.info.m_sDeptID;
                addUBankId1.Value = this.info.m_sFgs;

                LoadItem();
            }
        }

        /// <summary>
        /// 加载房屋设施
        /// </summary>
        public void LoadItem() 
        {
            DataTable dt = null;
            int total = 0;
            string condition = " where type='房屋设施'";

            using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.SystemParamDAL.p_system_param_list_table(1, 50, condition, ref total, db);
            }
            string arr = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;房屋设施";
            for (var i = 0; i < dt.Rows.Count; i++)
            {
                if (i % 8 == 0 && i > 0)
                {
                    arr += "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                }
                arr += "<input id='hAppliances' name='hAppliances' type='checkbox' />" + dt.Rows[i]["item"].ToString() + "";
            }

            divhAppliances.InnerHtml = arr + "<input id='btnCheck' class='button_bak' type='button' value='反选' onclick='SelectAll()' />&nbsp;&nbsp;<input id='btnCheckAll' class='button_bak' type='button' value='全选' onclick='SelectAll1()' />";
           
        }


    }
}
